//
//  MCCustomSpecificationsGoodsView.swift
//  StoreManage
//
//  Created by MC on 2018/4/26.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCCustomSpecificationsGoodsView: UIView {

    var model = MCGoodsManageHeadModel() {
        didSet {
            iconImageView.sd_setImage(with: URL.init(string: model.goodsPicture), placeholderImage: #imageLiteral(resourceName: "Reuse_placeholder_1_1"))
            nameLabel.text = model.goodsName
            moneyLabel.text = "售价:" + MCString_judgemantDecimalsIsZero(figure: model.lowestPrice.intValue) + "~" + MCString_judgemantDecimalsIsZero(figure: model.suggestedPrice.intValue)
            switch model.type.intValue {
            case 0:
                signLabel.text = "平台"
            case 1:
                signLabel.text = "自营"
            default:
                break
            }
        }
    }

    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self).inset(UIEdgeInsetsMake(0, 0, 0, 0))
        }
        
        bgView.addSubview(iconImageView)
        iconImageView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(bgView).offset(10)
            make.centerY.equalTo(bgView)
            make.size.equalTo(CGSize.init(width: 80, height: 80))
        }
        
        iconImageView.addSubview(signLabel)
        signLabel.snp.remakeConstraints { (make) ->Void in
            make.left.top.equalTo(iconImageView)
            make.size.equalTo(CGSize.init(width: 25, height: 15))
        }

        
        bgView.addSubview(nameLabel)
        nameLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.right.equalTo(bgView).offset(-10)
            make.top.equalTo(iconImageView).offset(2)
        }

        
        bgView.addSubview(moneyLabel)
        moneyLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.top.equalTo(nameLabel.snp.bottom).offset(5)
        }
        
        
        bgView.addSubview(countLabel)
        countLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.bottom.equalTo(iconImageView).offset(-2)
        }
        
        

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    lazy var iconImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.layer.borderColor = UIColor.MCGray_light.cgColor
        imageView.layer.borderWidth = 1
        imageView.image = #imageLiteral(resourceName: "Reuse_placeholder_1_1")
        return imageView
    }()
    
    
    lazy var signLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(10)
        label.backgroundColor = UIColor.MCMain
        label.textColor = UIColor.white
        label.textAlignment = NSTextAlignment.center
        return label
    }()
    
    
    public lazy var nameLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCBlack
        label.numberOfLines = 0
        return label
    }()
    
    public lazy var moneyLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCGray_middle
        return label
    }()
    
    public lazy var countLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCGray_middle
        return label
    }()


}
